// 抽象产品类：Product
abstract class Product {
    // 抽象方法，具体产品类需要实现
    public abstract void operation();
}

// 具体产品类：ConcreteProductA
class ConcreteProductA extends Product {
    @Override
    public void operation() {
        System.out.println("ConcreteProductA operation");
    }
}

// 具体产品类：另一个ConcreteProductA的变体
class AnotherConcreteProductA extends Product {
    @Override
    public void operation() {
        System.out.println("Another ConcreteProductA operation");
    }
}

// 工厂类：Factory
class Factory {
    // 工厂方法，返回Product类型的对象
    public Product factoryMethod(String type) {
        if (type == null) {
            return null;
        }
        if (type.equalsIgnoreCase("A")) {
            return new ConcreteProductA();
        } else if (type.equalsIgnoreCase("AnotherA")) {
            return new AnotherConcreteProductA();
        }
        return null;
    }
}

// 客户端代码
public class Client {
    public static void main(String[] args) {
        Factory factory = new Factory();
        
        // 获取ConcreteProductA的实例
        Product productA = factory.factoryMethod("A");
        productA.operation();
        
        // 获取AnotherConcreteProductA的实例
        Product anotherProductA = factory.factoryMethod("AnotherA");
        anotherProductA.operation();
    }
}